package com.mlf.observer.demo;

/**
 *  具体观察者，显示当前天气信息(部分)
 */
public class CurrentConditionsDisplay implements Observerz {
    private float temperature;
    private float humidity;
    private Subjects weatherData;

    public CurrentConditionsDisplay(Subjects weatherData) {
        this.weatherData = weatherData;
        // 注册
        weatherData.registerObserver(this);
    }
    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temperature = temp;
        this.humidity = humidity;
        display();
    }

    @Override
    public void update(Subjects subjects) {

    }

    public void display() {
        System.out.println("Current conditions: " + temperature + "F degrees and " + humidity + "% humidity");
    }
}
